/* Author: yangzeming
 * Date: 2013-12-10
 * Desc: 遮罩层
"blind
"bounce"
"clip"
"drop"
"explode"
fade
"fold"
"highlight"
"puff"
"pulsate"
"scale"
"shake"
"size"
"slide"
"transfer"
    
 */
define(function (require, exports, module) {

    var tab = _.Class({
        initial: function (option) {
            this._eventStack = {};
            var defaultOp = {
                effect: {
                    name: "normal",  // "blind",drop, clip, explode,fade
                    speed: 300
                }

            };
            this.option = $.extend(true, {}, defaultOp, option);
            this.$menu = $(option.menu);
            this.$content = $(option.content);

            this._start();

        },
        _start: function () {
            var self = this;
            this.$menu.delegate("[data-target]", "click", function () {
               
                
                var that = $(this),
					$target = that.data("target");
                self.$menu.find("[data-target]").removeClass(self.option.activeClass);
                that.addClass(self.option.activeClass);
                var target = self.$content.children("[data-target]"),
                    nt = target.filter(":visible"),
                    et = target.filter('[data-target="' + $target + '"]');
                self._effect(nt, et, self.option.effect["name"], $target);
                
            });

        },
        _normal: function (nt, et, $target) {
            nt.hide();
            et.show();
            self.trigger("clickMenu", $target);
        },
        _effect: function (nt, et, name, $target) {
            if (name == "normal") {
                this._normal(nt, et, $target);
            } else {
                var self = this;
                nt.effect(name, {}, this.option.effect.speed, function () {
                    et.effect(name, { "mode": "show" }, self.option.effect.speed, function () {
                        self.trigger("clickMenu", $target);
                
                }); });
            }
        }

    });
    module.exports = tab;
});